import axios from 'axios'

export interface IData<D>{
    code:number,
    msg:string,
    data:D
}

const instance =axios.create({
    timeout:1000,
    baseURL:''
})

//响应拦截器
instance.interceptors.response.use(
    res=>res.data,
    err =>Promise.reject(err)
)
//get
export const get =<T>(url:string,config:any={}) =>
    instance.get<any,IData<T>>(url,config)

//post
export const post =<T>(url:string,data:any,config:any={}) =>
    instance.post<any,IData<T>>(url,data,config)

//del
export const del =<T>(url:string, config:any={}) => 
instance.delete<any,IData<T>>(url, config)
